package net.chasing.androidbaseconfig.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.widget.NestedScrollView;

public class NoScrollNestScrollView extends NestedScrollView {
    private boolean enableScroll;

    public NoScrollNestScrollView(@NonNull Context context) {
        super(context);
    }

    public NoScrollNestScrollView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public NoScrollNestScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setEnableScroll(boolean enableScroll) {
        this.enableScroll = enableScroll;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (enableScroll)
            return super.onTouchEvent(ev);
        else
            return true;
    }
}
